﻿using AutoMapper;
using CustomerDTO;
using CustomerService;
using J.CustomerGet.Application.Command.CustomerListCommand;
using J.CustomerModel;
using J.CustomerRepository.Interface;
using MediatR;
using StatusDto;

namespace J.CustomerGet.Application.CommandHandler.CustomerListCommandHandler
{
    public class CustomerShowCommandHandler : IRequestHandler<CustomerShowCommand,PageDto<CustomerList>>
    {
        private readonly ICustomerListService _customerListService;
        private readonly IMapper mapper;
        public CustomerShowCommandHandler(ICustomerListService customerListService, IMapper _mapper)
        {
            _customerListService = customerListService;
            mapper = _mapper;
        }
        public async Task<PageDto<CustomerList>> Handle(CustomerShowCommand request, CancellationToken cancellationToken)
        {
            CustomerShowDto model = mapper.Map<CustomerShowDto>(request);
            return await _customerListService.GetCustomerShow(model);
        }
    }
}
